package com.uzai.console.web.sop;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.preserveuser.PreserveUserIdDto;
import com.uzai.console.dto.preserveuser.PreserveUserQuery;
import com.uzai.console.dto.preserveuser.PreserveUserSendMsgDto;
import com.uzai.console.dto.preserveuser.PreserveUserUpdateStatusDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.sop.PreserveUserService;
import com.uzai.console.vo.preserveuser.PreserveUserVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 待维护会员
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "待维护会员",tags = "客户维护|待维护会员")
@ApiSort(31)
@RestController
public class PreserveUserController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PreserveUserController.class);

    @Autowired
    private PreserveUserService preserveUserService;

    @ApiOperation(value = "分页查询待维护会员列表", notes = "分页查询待维护会员列表", response = PreserveUserVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/preserveUser/findByPage")
    public Object findPreserveUserPage(@RequestBody PreserveUserQuery preserveUserQuery){
        if(preserveUserQuery.getType() == null){
            preserveUserQuery.setType(0); //默认查询返利动态升级用户会员列表
        }
        return preserveUserService.findByPage(preserveUserQuery);
    }

    @ApiOperation(value = "查询待维护会员详情", notes = "查询待维护会员详情", response = PreserveUserVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/preserveUser/findById")
    public Object findPreserveUser(@RequestBody PreserveUserIdDto preserveUserIdDto){
        return preserveUserService.findById(preserveUserIdDto);
    }

    @SystemLogType(model = SystemModelEnum.PreserveUser, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除待维护会员", notes = "删除待维护会员")
    @ApiOperationSupport(order = 3)
    @PostMapping("/preserveUser/delete")
    public Object deletePreserveUser(@RequestBody PreserveUserIdDto preserveUserIdDto){
        preserveUserService.delete(preserveUserIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PreserveUser, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改待维护会员状态", notes = "修改待维护会员状态")
    @ApiOperationSupport(order = 4)
    @PostMapping("/preserveUser/updateStatus")
    public Object updateStatus(@RequestBody PreserveUserUpdateStatusDto preserveUserUpdateStatusDto){
        preserveUserService.updateStatus(preserveUserUpdateStatusDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PreserveUser, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "待维护会员发送消息", notes = "待维护会员发送消息")
    @ApiOperationSupport(order = 5)
    @PostMapping("/preserveUser/sendMsg")
    public Object sendMsg(@RequestBody PreserveUserSendMsgDto preserveUserSendMsgDtor){
        preserveUserService.sendMsg(preserveUserSendMsgDtor);
        return true;
    }

    @ApiOperation(value = "分页查询SOP提现风控会员列表", notes = "分页查询SOP提现风控会员列表", response = PreserveUserVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/preserveUser/takeRisk/findByPage")
    public Object findPreserveUserPageByTakeRisk(@RequestBody PreserveUserQuery preserveUserQuery){
        preserveUserQuery.setType(1); //查询提现异常的待维护会员
        return preserveUserService.findByPage(preserveUserQuery);
    }

}
